package com.video;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.app.util.Utils;
import com.example.com.skills_utf8.R;
import com.utils.Utils1;

import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;



// http://xiehongdong.iteye.com/blog/1147987
public class PlayVideoActivity extends Activity {

    PlayVideoActivity activity = this;

    DisplayMetrics display_metrics = new DisplayMetrics();



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_video);


        System.out.println("onCreate");



        ///*	需要依赖工程
		if (!LibsChecker.checkVitamioLibs(this))
			return;
		//*/


        String path = getIntent().getStringExtra("path");


        VideoView vv_content = (VideoView)findViewById(R.id.vv_content);


        vv_content.setVideoPath(path);
        vv_content.setMediaController(new MediaController(this));
        vv_content.requestFocus();

        vv_content.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                // optional need Vitamio 4.0
                mediaPlayer.setPlaybackSpeed(1.0f);
            }
        });



        activity.getWindowManager().getDefaultDisplay().getMetrics(display_metrics);


        Button btn_change = (Button)findViewById(R.id.btn_change);
        btn_change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {



            int h = display_metrics.widthPixels;
            int w = display_metrics.heightPixels;
            if(w < h){
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }else{
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            }




            }
        });



        

    }


    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

    }


}
